Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: resample does not yield empty groups (#10603) #35799

Merged
merged 3 commits into from
Aug 21, 2020

Conversation

tkmz-n
Copy link
Contributor

@tkmz-n tkmz-n commented Aug 19, 2020

This adds a test to verify that resample does not yield empty groups.

I'm new to contributing to pandas, and I'm not sure where to add this test.
Let me know if this place is inappropriate.

Copy link
Member

@arw2019 arw2019 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @tkmz-n

some small comments, o/w lgtm

def test_resample_timedelta_no_empty_groups():
# GH 10603
# check that resample does not yield empty groups
df = pd.DataFrame(np.random.normal(size=(10000, 4)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define df in a single step: pd.DataFrame(..., index=...)

df.index = pd.timedelta_range(start="0s", periods=10000, freq="3906250n")
result = df.loc["1s":, :].resample("3s").apply(lambda x: len(x))

expected = pd.DataFrame([[768.0] * 4] * 12 + [[528.0] * 4])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


def test_resample_timedelta_no_empty_groups():
# GH 10603
# check that resample does not yield empty groups
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: this comment is maybe spurious

@@ -150,3 +150,15 @@ def test_resample_timedelta_edge_case(start, end, freq, resample_freq):
tm.assert_index_equal(result.index, expected_index)
assert result.index.freq == expected_index.freq
assert not np.isnan(result[-1])


def test_resample_timedelta_no_empty_groups():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: test_resample_with_timedelta_yields_no_empty_groups

Just to make it easier to tell what the test does if we see it failing

@tkmz-n tkmz-n force-pushed the test-resample-empty-groups branch from a731549 to aba2a1f Compare August 20, 2020 16:11
@alimcmaster1
Copy link
Member

If you merge master CI failures should be resolved

@jreback jreback added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Resample resample method Testing pandas testing functions or related to the test suite labels Aug 21, 2020
@jreback jreback added this to the 1.2 milestone Aug 21, 2020
@jreback jreback merged commit e2a622c into pandas-dev:master Aug 21, 2020
@jreback
Copy link
Contributor

jreback commented Aug 21, 2020

thanks @tkmz-n very nice

jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Aug 22, 2020
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Aug 23, 2020
mroeschke pushed a commit that referenced this pull request Aug 31, 2020
* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (#35630)

* TST: resample does not yield empty groups (#10603) (#35799)

* revert accidental rebase

* REF: use BlockManager.apply for Rolling.count

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
jbrockmendel added a commit to jbrockmendel/pandas that referenced this pull request Aug 31, 2020
* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (pandas-dev#35630)

* TST: resample does not yield empty groups (pandas-dev#10603) (pandas-dev#35799)

* revert accidental rebase

* REF: use BlockManager.apply for Rolling.count

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
jreback pushed a commit that referenced this pull request Sep 2, 2020
…ce (#35899)

* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (#35630)

* TST: resample does not yield empty groups (#10603) (#35799)

* revert accidental rebase

* REF: handle axis=None cases inside DataFrame.all/any

* annotate

* dummy commit to force Travis

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
jreback pushed a commit that referenced this pull request Sep 2, 2020
* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (#35630)

* TST: resample does not yield empty groups (#10603) (#35799)

* revert accidental rebase

* BUG: BlockSlider not clearing index._cache

* update whatsnew

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
jreback pushed a commit that referenced this pull request Sep 2, 2020
…36045)

* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (#35630)

* TST: resample does not yield empty groups (#10603) (#35799)

* revert accidental rebase

* BUG: NDFrame.replace wrong exception type, wrong return when size==0

* bool->bool_t

* whatsnew

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (pandas-dev#35630)

* TST: resample does not yield empty groups (pandas-dev#10603) (pandas-dev#35799)

* revert accidental rebase

* REF: use BlockManager.apply for Rolling.count

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
…ce (pandas-dev#35899)

* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (pandas-dev#35630)

* TST: resample does not yield empty groups (pandas-dev#10603) (pandas-dev#35799)

* revert accidental rebase

* REF: handle axis=None cases inside DataFrame.all/any

* annotate

* dummy commit to force Travis

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (pandas-dev#35630)

* TST: resample does not yield empty groups (pandas-dev#10603) (pandas-dev#35799)

* revert accidental rebase

* BUG: BlockSlider not clearing index._cache

* update whatsnew

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
…andas-dev#36045)

* REF: remove unnecesary try/except

* TST: add test for agg on ordered categorical cols (pandas-dev#35630)

* TST: resample does not yield empty groups (pandas-dev#10603) (pandas-dev#35799)

* revert accidental rebase

* BUG: NDFrame.replace wrong exception type, wrong return when size==0

* bool->bool_t

* whatsnew

Co-authored-by: Karthik Mathur <[email protected]>
Co-authored-by: tkmz-n <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Resample resample method Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resample yields empty groups
4 participants